//
//  CommonCtrView.m
//  MyItem
//
//  Created by SoulWater on 16/1/4.
//  Copyright © 2016年 admin. All rights reserved.
//

#import "CommonCtrView.h"

@implementation CommonCtrView
- (void)_createPicAndLab:(NSString *)ImageName andImagwScale:(CGFloat)scale andBottomLabText:(NSString *)text{
    CGFloat imageHeight = 0.5 * self.bounds.size.height;
    CGFloat imageWidth = scale * imageHeight;
    CGFloat space = (self.bounds.size.width - imageWidth) / 2;
    //1、创建子视图
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(space, 0.1 * self.bounds.size.height,imageWidth, imageHeight)];
    imageView.image = [UIImage imageNamed:ImageName];
    //设置图片适应
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:imageView];
    
    //2、创建标题视图
    CGFloat lableHeight = 0.2 * self.bounds.size.height;
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0.6 * self.bounds.size.height, self.bounds.size.width,lableHeight)];
    //设置label内容
    titleLabel.text = text;
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = [UIFont systemFontOfSize:12];
    [self addSubview:titleLabel];
}

- (void)_createPictureAndRightLabel:(NSString *)imageName imageScale:(CGFloat)scale labelText:(NSString *)text{
    
    CGFloat imageHeight = 0.8 * self.bounds.size.height;
    CGFloat imageWidth = scale * imageHeight - 30;
    CGFloat space = (self.bounds.size.width - imageWidth) / 2;
    
    UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(space, 0.1*self.bounds.size.height, imageWidth, imageHeight)];
    imgView.image = [UIImage imageNamed:imageName];
    
    imgView.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:imgView];
    
    CGFloat labelHeight = 0.2 * self.bounds.size.height;
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(space + imageWidth + 3, (self.bounds.size.height-labelHeight)/2, 30, labelHeight)];
    titleLabel.text = text;
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.font = [UIFont systemFontOfSize:12];
    [self addSubview:titleLabel];
}


- (void)_createLabAndLab:(NSString *)topLabText andBotton:(NSString *)bottomLabText;{
    CGFloat labelHeight = 0.5 * self.bounds.size.height;
    CGFloat labelWidth = 0.8 * self.bounds.size.width;
    CGFloat space = (self.bounds.size.width - labelWidth) / 2;
    //创建上方Lable
    UILabel *topLabel = [[UILabel alloc] initWithFrame:CGRectMake(space, 0, labelWidth,labelHeight)];
    topLabel.text = topLabText;
    topLabel.textColor = [UIColor blackColor];
    topLabel.textAlignment = NSTextAlignmentCenter;
    topLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:topLabel];
    //创建下方Lable
    UILabel *bottomLabel = [[UILabel alloc] initWithFrame:CGRectMake(space, labelHeight, labelWidth,labelHeight)];
    bottomLabel.text = bottomLabText;
    bottomLabel.textColor = [UIColor grayColor];
    bottomLabel.textAlignment = NSTextAlignmentCenter;
    bottomLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:bottomLabel];
    
}
@end
